package com.redpack.redpost.struts.form;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

import com.redpack.redpost.util.dao.UserDAO;
import com.redpack.redpost.util.dao.adminDAO;

public class recuperaForm extends ActionForm {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private String email ;
	private String email_confirm ;
	
		
	
	public String getEmail() {
		return email;
	}



	public void setEmail(String email) {
		this.email = email;
	}



	public String getEmail_confirm() {
		return email_confirm;
	}



	public void setEmail_confirm(String email_confirm) {
		this.email_confirm = email_confirm;
	}



	public static long getSerialversionuid() {
		return serialVersionUID;
	}



	public ActionErrors validate(ActionMapping mapping, HttpServletRequest request){
		
		ActionErrors errors = new ActionErrors() ;
		
		
		HttpSession session = request.getSession( ) ;
		String idioma = "";
		
	
		if (session.getAttribute("idioma") != null && session.getAttribute("idioma") != ""){
			idioma = session.getAttribute("idioma").toString();
	
		}
		
		
		if (email == null || email.trim().length() == 0) {
			if(idioma.equals("")){
				errors.add("EmailVacio", new ActionMessage("com.redpack.redpost.web.errors.modules.contactanos.email"));
			}
			if(idioma.equals("Eng")){
				errors.add("EmailVacio", new ActionMessage("com.redpack.redpost.web.errors.modules.contactanos.emailEng"));
			}
			
            
        }else{
        	if (email_confirm == null || email_confirm.trim().length() == 0) {
        		if(idioma.equals("")){
        			errors.add("EmailconfVacio", new ActionMessage("com.redpack.redpost.web.errors.modules.registro.emailConf"));
    			}
    			if(idioma.equals("Eng")){
    				errors.add("EmailconfVacio", new ActionMessage("com.redpack.redpost.web.errors.modules.registro.emailConfEng"));
    			}
    			
        		
        	}else{
        		if ( !email_confirm.equals(email) ) {
        			if(idioma.equals("")){
        				errors.add("EmailNoCheca", new ActionMessage("com.redpack.redpost.web.errors.modules.registro.emailNoCheca"));
        			}
        			if(idioma.equals("Eng")){
        				errors.add("EmailNoCheca", new ActionMessage("com.redpack.redpost.web.errors.modules.registro.emailNoChecaEng"));
        			}
        			
            		
            	}
        	}
        }
		
		if ( errors.size() > 0 ){
			request.setAttribute("email", email);
			request.setAttribute("email_confirm", email_confirm);
		}
		
		return errors ;
		
	}

}
